{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "from keras.models import Model\n",
    "from keras.layers import Input\n",
    "from keras.layers.pooling import MaxPooling3D\n",
    "from keras import backend as K\n",
    "import json\n",
    "from collections import OrderedDict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def format_decimal(arr, places=6):\n",
    "    return [round(x * 10**places) / 10**places for x in arr]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "DATA = OrderedDict()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### MaxPooling3D"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**[pooling.MaxPooling3D.0] input 4x4x4x2, pool_size=(2, 2, 2), strides=None, padding='valid', data_format='channels_last'**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "in shape: (4, 4, 4, 2)\n",
      "in: [-0.453175, -0.475078, 0.486234, -0.949643, -0.349099, -0.837108, 0.933439, 0.167853, -0.995191, 0.459466, -0.788337, -0.120985, 0.06215, 0.138625, -0.102201, 0.976605, -0.591051, -0.592066, 0.469334, -0.435067, 0.621416, 0.817698, 0.790015, 0.485862, 0.469679, -0.611443, 0.582845, -0.503885, -0.379174, -0.451035, 0.052289, 0.131836, -0.609312, -0.828722, -0.422428, -0.648754, -0.339801, -0.758017, 0.754244, -0.544823, 0.691656, 0.076848, -0.32539, 0.306448, -0.662415, 0.334329, 0.030666, -0.414111, -0.757096, -0.20427, -0.893088, -0.681919, -0.619269, -0.640749, 0.867436, 0.971453, -0.42039, -0.574905, -0.34642, 0.588678, -0.247265, 0.436084, 0.220126, 0.114202, 0.613623, 0.401452, -0.270262, -0.591146, -0.872383, 0.818368, 0.336808, 0.338197, -0.275646, 0.375308, -0.928722, -0.836727, -0.504007, -0.503397, -0.636099, 0.948482, -0.639661, -0.026878, -0.122643, -0.634018, -0.247016, 0.517246, -0.398639, 0.752174, -0.014633, -0.170534, -0.463453, -0.289716, 0.837207, 0.769962, -0.401357, 0.076406, 0.270433, -0.036538, -0.05766, 0.625256, 0.626847, -0.27321, -0.217219, -0.775553, -0.182939, 0.327385, -0.976376, -0.337729, -0.178467, -0.1545, -0.334259, -0.537949, 0.499229, 0.775269, -0.657598, 0.921864, 0.376821, 0.420375, -0.937835, -0.176425, -0.516753, 0.737286, 0.867807, -0.515893, 0.710035, 0.680377, -0.350561, -0.28645]\n",
      "out shape: (2, 2, 2, 2)\n",
      "out: [0.691656, 0.459466, 0.933439, 0.976605, 0.582845, 0.588678, 0.867436, 0.971453, 0.613623, 0.625256, 0.626847, 0.948482, 0.867807, 0.921864, 0.837207, 0.769962]\n"
     ]
    }
   ],
   "source": [
    "data_in_shape = (4, 4, 4, 2)\n",
    "L = MaxPooling3D(pool_size=(2, 2, 2), strides=None, padding='valid', data_format='channels_last')\n",
    "\n",
    "layer_0 = Input(shape=data_in_shape)\n",
    "layer_1 = L(layer_0)\n",
    "model = Model(inputs=layer_0, outputs=layer_1)\n",
    "\n",
    "# set weights to random (use seed for reproducibility)\n",
    "np.random.seed(290)\n",
    "data_in = 2 * np.random.random(data_in_shape) - 1\n",
    "result = model.predict(np.array([data_in]))\n",
    "data_out_shape = result[0].shape\n",
    "data_in_formatted = format_decimal(data_in.ravel().tolist())\n",
    "data_out_formatted = format_decimal(result[0].ravel().tolist())\n",
    "print('')\n",
    "print('in shape:', data_in_shape)\n",
    "print('in:', data_in_formatted)\n",
    "print('out shape:', data_out_shape)\n",
    "print('out:', data_out_formatted)\n",
    "\n",
    "DATA['pooling.MaxPooling3D.0'] = {\n",
    "    'input': {'data': data_in_formatted, 'shape': data_in_shape},\n",
    "    'expected': {'data': data_out_formatted, 'shape': data_out_shape}\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**[pooling.MaxPooling3D.1] input 4x4x4x2, pool_size=(2, 2, 2), strides=(1, 1, 1), padding='valid', data_format='channels_last'**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "in shape: (4, 4, 4, 2)\n",
      "in: [-0.803361, 0.348731, 0.30124, -0.168638, 0.516406, -0.258765, 0.297839, 0.993235, 0.958465, -0.273175, -0.704992, 0.261477, -0.301255, 0.263104, 0.678631, -0.644936, -0.029034, -0.320266, 0.307733, -0.479016, 0.608177, 0.034951, 0.456908, -0.929353, 0.594982, -0.243058, -0.524918, 0.455339, 0.034216, 0.356824, 0.63906, -0.259773, -0.084724, 0.248472, -0.608134, 0.0077, 0.400591, -0.960703, -0.247926, -0.774509, 0.496174, -0.319044, -0.324046, -0.616632, -0.322142, -0.472846, 0.171825, -0.030013, 0.992861, -0.645264, 0.524886, 0.673229, 0.883122, 0.25346, -0.706988, -0.654436, 0.918349, -0.139113, 0.742737, 0.338472, -0.812719, 0.860081, 0.003489, 0.667897, 0.362284, -0.283972, 0.995162, 0.67962, -0.700244, -0.137142, 0.045695, -0.450433, 0.929977, 0.157542, -0.720517, -0.939063, 0.295004, 0.308728, -0.094057, -0.374756, -0.400976, -0.539654, 0.27965, 0.977688, -0.361264, -0.027757, -0.67149, 0.57064, -0.861888, 0.616985, -0.027436, 0.40181, -0.30391, 0.92268, -0.486416, -0.335828, 0.138558, -0.445691, 0.156253, -0.967633, 0.127471, -0.783301, -0.691353, -0.76759, 0.618771, -0.377474, 0.50152, 0.126867, -0.872708, 0.649418, 0.697987, -0.33456, 0.906767, 0.604333, -0.129366, 0.579445, -0.033479, -0.22433, -0.979529, -0.251153, 0.839734, 0.550506, -0.599678, 0.584326, 0.211245, -0.66845, 0.948298, -0.004521]\n",
      "out shape: (3, 3, 3, 2)\n",
      "out: [0.958466, 0.348731, 0.516406, 0.263104, 0.678631, 0.993235, 0.992861, 0.673229, 0.883122, 0.673229, 0.883122, 0.263104, 0.992861, 0.673229, 0.883122, 0.860081, 0.883122, 0.860081, 0.995162, 0.67962, 0.995162, 0.67962, 0.400591, 0.308728, 0.992861, 0.977688, 0.883122, 0.977688, 0.883122, 0.57064, 0.992861, 0.977688, 0.883122, 0.977688, 0.883122, 0.92268, 0.995162, 0.67962, 0.995162, 0.67962, 0.697987, 0.649418, 0.929977, 0.977688, 0.50152, 0.977688, 0.697987, 0.649418, 0.906767, 0.977688, 0.27965, 0.977688, 0.948298, 0.92268]\n"
     ]
    }
   ],
   "source": [
    "data_in_shape = (4, 4, 4, 2)\n",
    "L = MaxPooling3D(pool_size=(2, 2, 2), strides=(1, 1, 1), padding='valid', data_format='channels_last')\n",
    "\n",
    "layer_0 = Input(shape=data_in_shape)\n",
    "layer_1 = L(layer_0)\n",
    "model = Model(inputs=layer_0, outputs=layer_1)\n",
    "\n",
    "# set weights to random (use seed for reproducibility)\n",
    "np.random.seed(291)\n",
    "data_in = 2 * np.random.random(data_in_shape) - 1\n",
    "result = model.predict(np.array([data_in]))\n",
    "data_out_shape = result[0].shape\n",
    "data_in_formatted = format_decimal(data_in.ravel().tolist())\n",
    "data_out_formatted = format_decimal(result[0].ravel().tolist())\n",
    "print('')\n",
    "print('in shape:', data_in_shape)\n",
    "print('in:', data_in_formatted)\n",
    "print('out shape:', data_out_shape)\n",
    "print('out:', data_out_formatted)\n",
    "\n",
    "DATA['pooling.MaxPooling3D.1'] = {\n",
    "    'input': {'data': data_in_formatted, 'shape': data_in_shape},\n",
    "    'expected': {'data': data_out_formatted, 'shape': data_out_shape}\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**[pooling.MaxPooling3D.2] input 4x5x2x3, pool_size=(2, 2, 2), strides=(2, 1, 1), padding='valid', data_format='channels_last'**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "in shape: (4, 5, 2, 3)\n",
      "in: [-0.263147, -0.216555, -0.75766, -0.396007, 0.85243, 0.98415, -0.230197, -0.979579, 0.117628, -0.66833, 0.714058, -0.907302, -0.574249, 0.299573, 0.101165, 0.655872, -0.104788, 0.242064, -0.409262, -0.124059, 0.105687, -0.969325, -0.167941, 0.382377, 0.710487, 0.793042, 0.180663, -0.80231, 0.684253, -0.516992, 0.471203, -0.152325, 0.509501, 0.613742, -0.877379, 0.755416, 0.427677, 0.931956, 0.827636, -0.860685, 0.562326, -0.716081, 0.028046, 0.594422, -0.862333, 0.336131, 0.713855, 0.386247, -0.986659, 0.242413, 0.753777, -0.159358, 0.166548, -0.437388, 0.291152, -0.775555, 0.796086, -0.592021, -0.251661, 0.187174, 0.899283, 0.431861, -0.685273, -0.085991, -0.629026, -0.478334, 0.714983, 0.53745, -0.310438, 0.973848, -0.675219, 0.422743, -0.992263, 0.374017, -0.687462, -0.190455, -0.560081, 0.22484, -0.079631, 0.815275, 0.338641, -0.538279, -0.10891, -0.929005, 0.514762, 0.322038, 0.702195, -0.697122, 0.925468, -0.274158, 0.148379, 0.333239, 0.63072, -0.652956, -0.356451, -0.71114, 0.111465, 0.31787, 0.242578, 0.8926, -0.60807, 0.218759, 0.42079, 0.71253, -0.082496, 0.272704, 0.277213, -0.099807, -0.899322, -0.175367, -0.642213, -0.661032, 0.730145, 0.37799, 0.935939, -0.448007, -0.320652, -0.352629, 0.258139, 0.30254]\n",
      "out shape: (2, 4, 1, 3)\n",
      "out: [0.613742, 0.931956, 0.98415, 0.655872, 0.931956, 0.827636, 0.655872, 0.713855, 0.753777, 0.710487, 0.793042, 0.796086, 0.973848, 0.53745, 0.63072, 0.973848, 0.71253, 0.422743, 0.42079, 0.815275, 0.37799, 0.935939, 0.925468, 0.702195]\n"
     ]
    }
   ],
   "source": [
    "data_in_shape = (4, 5, 2, 3)\n",
    "L = MaxPooling3D(pool_size=(2, 2, 2), strides=(2, 1, 1), padding='valid', data_format='channels_last')\n",
    "\n",
    "layer_0 = Input(shape=data_in_shape)\n",
    "layer_1 = L(layer_0)\n",
    "model = Model(inputs=layer_0, outputs=layer_1)\n",
    "\n",
    "# set weights to random (use seed for reproducibility)\n",
    "np.random.seed(282)\n",
    "data_in = 2 * np.random.random(data_in_shape) - 1\n",
    "result = model.predict(np.array([data_in]))\n",
    "data_out_shape = result[0].shape\n",
    "data_in_formatted = format_decimal(data_in.ravel().tolist())\n",
    "data_out_formatted = format_decimal(result[0].ravel().tolist())\n",
    "print('')\n",
    "print('in shape:', data_in_shape)\n",
    "print('in:', data_in_formatted)\n",
    "print('out shape:', data_out_shape)\n",
    "print('out:', data_out_formatted)\n",
    "\n",
    "DATA['pooling.MaxPooling3D.2'] = {\n",
    "    'input': {'data': data_in_formatted, 'shape': data_in_shape},\n",
    "    'expected': {'data': data_out_formatted, 'shape': data_out_shape}\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**[pooling.MaxPooling3D.3] input 4x4x4x2, pool_size=(3, 3, 3), strides=None, padding='valid', data_format='channels_last'**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "in shape: (4, 4, 4, 2)\n",
      "in: [0.19483, -0.346754, 0.281648, -0.656271, 0.588328, 0.864284, -0.661556, 0.344578, 0.534692, 0.187914, -0.172976, 0.100575, 0.287857, 0.151936, 0.679748, 0.137527, 0.726773, -0.503042, -0.902524, -0.895315, 0.870645, 0.792427, -0.102238, -0.748643, -0.048728, -0.025835, 0.358631, 0.804295, -0.300104, -0.99179, -0.699454, -0.943476, -0.448011, 0.628611, 0.060595, 0.716813, -0.33607, 0.549002, 0.810379, 0.074881, -0.689823, 0.17513, -0.975426, 0.961779, -0.030624, -0.914643, -0.735591, 0.031988, -0.554272, 0.253033, 0.73405, 0.426412, -0.361457, 0.787875, -0.266747, -0.166595, 0.922155, -0.04597, -0.465312, 0.157074, -0.201136, -0.004584, -0.158067, 0.244864, -0.495687, 0.416834, -0.583545, 0.654634, -0.318258, -0.709804, -0.393463, 0.589381, -0.900991, 0.266171, 0.955916, -0.6571, 0.990855, -0.078764, 0.609356, -0.526011, -0.902476, 0.040574, -0.045497, -0.110604, 0.035908, -0.91532, -0.170028, -0.02148, -0.994139, 0.020418, 0.989168, -0.802385, 0.353583, -0.981395, -0.959128, 0.785969, -0.325003, -0.541583, -0.929888, 0.40832, 0.565713, 0.449217, -0.21377, -0.491438, -0.352481, 0.469042, 0.272024, 0.101279, -0.70562, -0.296457, 0.210789, -0.049051, -0.002596, 0.630726, 0.023403, -0.216062, 0.510835, -0.446393, -0.075211, 0.4807, 0.581605, 0.705887, 0.741715, -0.448041, 0.88241, -0.866934, -0.341714, -0.245376]\n",
      "out shape: (1, 1, 1, 2)\n",
      "out: [0.990855, 0.961779]\n"
     ]
    }
   ],
   "source": [
    "data_in_shape = (4, 4, 4, 2)\n",
    "L = MaxPooling3D(pool_size=(3, 3, 3), strides=None, padding='valid', data_format='channels_last')\n",
    "\n",
    "layer_0 = Input(shape=data_in_shape)\n",
    "layer_1 = L(layer_0)\n",
    "model = Model(inputs=layer_0, outputs=layer_1)\n",
    "\n",
    "# set weights to random (use seed for reproducibility)\n",
    "np.random.seed(283)\n",
    "data_in = 2 * np.random.random(data_in_shape) - 1\n",
    "result = model.predict(np.array([data_in]))\n",
    "data_out_shape = result[0].shape\n",
    "data_in_formatted = format_decimal(data_in.ravel().tolist())\n",
    "data_out_formatted = format_decimal(result[0].ravel().tolist())\n",
    "print('')\n",
    "print('in shape:', data_in_shape)\n",
    "print('in:', data_in_formatted)\n",
    "print('out shape:', data_out_shape)\n",
    "print('out:', data_out_formatted)\n",
    "\n",
    "DATA['pooling.MaxPooling3D.3'] = {\n",
    "    'input': {'data': data_in_formatted, 'shape': data_in_shape},\n",
    "    'expected': {'data': data_out_formatted, 'shape': data_out_shape}\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**[pooling.MaxPooling3D.4] input 4x4x4x2, pool_size=(3, 3, 3), strides=(3, 3, 3), padding='valid', data_format='channels_last'**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "in shape: (4, 4, 4, 2)\n",
      "in: [0.691755, -0.79282, -0.953135, 0.756956, -0.736874, 0.171061, -0.801845, 0.588236, -0.884749, 0.06721, -0.585121, -0.546211, -0.605281, -0.998989, 0.309413, -0.260604, -0.123585, 0.168908, -0.179496, 0.657412, -0.973664, 0.146258, -0.851615, -0.320588, 0.375102, -0.048494, 0.822789, 0.063572, -0.956466, 0.083595, 0.121146, 0.789353, -0.815498, -0.056454, -0.472042, -0.423572, 0.460752, 0.784129, -0.964421, -0.02912, -0.194265, 0.17147, -0.336383, -0.785223, 0.978845, 0.88826, -0.498649, -0.958507, 0.055052, -0.991654, -0.027882, 0.079693, 0.901998, 0.036266, -0.73015, -0.472116, 0.651073, 0.821196, 0.562183, 0.42342, -0.236111, 0.661076, -0.983951, -0.116893, -0.179815, 0.375962, -0.018703, -0.242038, -0.561415, 0.322072, 0.468695, 0.768235, -0.354887, 0.528139, 0.796988, -0.976979, 0.279858, -0.790546, 0.485339, 0.693701, -0.130412, 0.211269, -0.346429, 0.06497, 0.932512, -0.675758, -0.636085, 0.065187, -0.720225, -0.060809, -0.783716, -0.1708, 0.256143, 0.365727, -0.458241, 0.515217, -0.269055, 0.378065, 0.066507, 0.207271, -0.303131, 0.632455, 0.147251, 0.35156, -0.852052, -0.382054, 0.42108, -0.350071, 0.092818, 0.516404, 0.448487, 0.503722, -0.86555, 0.747871, 0.320894, -0.163714, 0.107681, 0.562623, 0.757089, 0.85338, -0.875069, 0.324594, -0.093024, 0.016279, -0.507882, -0.549638, -0.913588, 0.078328]\n",
      "out shape: (1, 1, 1, 2)\n",
      "out: [0.978845, 0.88826]\n"
     ]
    }
   ],
   "source": [
    "data_in_shape = (4, 4, 4, 2)\n",
    "L = MaxPooling3D(pool_size=(3, 3, 3), strides=(3, 3, 3), padding='valid', data_format='channels_last')\n",
    "\n",
    "layer_0 = Input(shape=data_in_shape)\n",
    "layer_1 = L(layer_0)\n",
    "model = Model(inputs=layer_0, outputs=layer_1)\n",
    "\n",
    "# set weights to random (use seed for reproducibility)\n",
    "np.random.seed(284)\n",
    "data_in = 2 * np.random.random(data_in_shape) - 1\n",
    "result = model.predict(np.array([data_in]))\n",
    "data_out_shape = result[0].shape\n",
    "data_in_formatted = format_decimal(data_in.ravel().tolist())\n",
    "data_out_formatted = format_decimal(result[0].ravel().tolist())\n",
    "print('')\n",
    "print('in shape:', data_in_shape)\n",
    "print('in:', data_in_formatted)\n",
    "print('out shape:', data_out_shape)\n",
    "print('out:', data_out_formatted)\n",
    "\n",
    "DATA['pooling.MaxPooling3D.4'] = {\n",
    "    'input': {'data': data_in_formatted, 'shape': data_in_shape},\n",
    "    'expected': {'data': data_out_formatted, 'shape': data_out_shape}\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**[pooling.MaxPooling3D.5] input 4x4x4x2, pool_size=(2, 2, 2), strides=None, padding='same', data_format='channels_last'**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "in shape: (4, 4, 4, 2)\n",
      "in: [-0.495196, -0.886872, 0.220815, 0.126844, 0.168234, -0.640849, 0.457897, -0.375014, 0.001134, -0.486501, -0.819617, -0.468351, 0.15859, 0.39238, -0.590545, -0.402922, 0.821619, -0.208255, -0.512219, -0.586151, -0.365648, -0.195611, -0.280978, -0.08818, -0.449229, 0.169082, 0.075074, -0.719751, 0.657827, -0.060862, -0.217533, 0.907503, 0.902317, 0.613945, 0.670047, -0.808346, 0.060215, -0.446612, -0.710328, -0.018744, 0.348018, -0.294409, 0.623986, -0.216504, 0.270099, -0.216285, -0.433193, -0.197968, -0.829926, -0.93864, -0.901724, -0.388869, -0.658339, -0.931401, -0.654674, -0.469503, 0.970661, 0.008063, -0.751014, 0.519043, 0.197895, 0.959095, 0.875405, 0.700615, 0.301314, -0.980157, 0.275373, -0.082646, 0.100727, -0.027273, -0.322366, 0.26563, 0.668139, 0.890289, 0.854229, -0.85773, -0.07833, -0.319645, -0.948873, 0.403526, 0.683097, 0.174958, 0.926944, -0.418256, -0.406667, -0.333808, 0.102223, -0.00576, 0.182281, 0.979655, 0.230246, 0.422968, -0.381217, 0.146697, 0.660828, 0.060741, -0.201812, 0.587619, 0.188211, -0.652713, -0.937225, -0.814998, 0.277993, -0.539363, -0.665425, 0.72739, 0.919326, 0.710163, -0.819091, -0.089805, -0.778517, -0.593048, 0.945303, -0.078936, 0.303422, 0.206755, -0.899923, -0.868598, 0.249905, -0.47891, 0.006871, -0.263386, -0.484493, -0.75917, 0.857292, 0.401094, -0.077826, -0.44546]\n",
      "out shape: (2, 2, 2, 2)\n",
      "out: [0.902317, 0.613945, 0.457897, 0.39238, 0.970661, 0.519043, 0.875405, 0.959095, 0.919326, 0.890289, 0.277993, 0.403526, 0.945303, 0.979655, 0.857292, 0.401094]\n"
     ]
    }
   ],
   "source": [
    "data_in_shape = (4, 4, 4, 2)\n",
    "L = MaxPooling3D(pool_size=(2, 2, 2), strides=None, padding='same', data_format='channels_last')\n",
    "\n",
    "layer_0 = Input(shape=data_in_shape)\n",
    "layer_1 = L(layer_0)\n",
    "model = Model(inputs=layer_0, outputs=layer_1)\n",
    "\n",
    "# set weights to random (use seed for reproducibility)\n",
    "np.random.seed(285)\n",
    "data_in = 2 * np.random.random(data_in_shape) - 1\n",
    "result = model.predict(np.array([data_in]))\n",
    "data_out_shape = result[0].shape\n",
    "data_in_formatted = format_decimal(data_in.ravel().tolist())\n",
    "data_out_formatted = format_decimal(result[0].ravel().tolist())\n",
    "print('')\n",
    "print('in shape:', data_in_shape)\n",
    "print('in:', data_in_formatted)\n",
    "print('out shape:', data_out_shape)\n",
    "print('out:', data_out_formatted)\n",
    "\n",
    "DATA['pooling.MaxPooling3D.5'] = {\n",
    "    'input': {'data': data_in_formatted, 'shape': data_in_shape},\n",
    "    'expected': {'data': data_out_formatted, 'shape': data_out_shape}\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**[pooling.MaxPooling3D.6] input 4x4x4x2, pool_size=(2, 2, 2), strides=(1, 1, 1), padding='same', data_format='channels_last'**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "in shape: (4, 4, 4, 2)\n",
      "in: [-0.709952, -0.532913, -0.169956, -0.391538, 0.729034, -0.2004, -0.67324, -0.973672, 0.879975, -0.981827, -0.4828, -0.887985, 0.843364, 0.710745, -0.260613, 0.20082, 0.309563, 0.721671, -0.967848, -0.976471, -0.13058, 0.052684, 0.666494, -0.319759, -0.060338, 0.359151, -0.795562, 0.70488, 0.100816, 0.466479, 0.992415, 0.066527, -0.690663, -0.741365, -0.251801, -0.479328, 0.62187, 0.578729, 0.598481, 0.817115, -0.913801, -0.694569, 0.397726, -0.31274, 0.163147, 0.087004, -0.744957, -0.920201, 0.440377, -0.191648, -0.227724, -0.562736, -0.484598, -0.230876, 0.019055, 0.988723, 0.656988, 0.185623, -0.629304, -0.321252, 0.329452, 0.355461, 0.734458, 0.496983, 0.181439, 0.414232, 0.776873, 0.68191, -0.846744, -0.442164, -0.526272, 0.92696, -0.704629, -0.800248, 0.643923, 0.775996, -0.203863, -0.756864, -0.398058, -0.914275, 0.980404, 0.329099, -0.576086, 0.851052, -0.74133, -0.23673, -0.001628, 0.972916, -0.571033, 0.669151, -0.977945, -0.707472, 0.371069, -0.772292, -0.207482, -0.094619, -0.604913, 0.111706, -0.123427, 0.284132, 0.292284, -0.490954, -0.873365, 0.109881, -0.40172, 0.103223, 0.396366, -0.415444, 0.766823, -0.057373, 0.619422, 0.30151, -0.126582, 0.862041, -0.083425, -0.018503, 0.744106, -0.681409, 0.556506, -0.628066, -0.697587, -0.201239, 0.051677, -0.585768, 0.202332, -0.634928, -0.410351, 0.005911]\n",
      "out shape: (4, 4, 4, 2)\n",
      "out: [0.879975, -0.31274, 0.843364, 0.710745, 0.843364, 0.817115, 0.598481, 0.817115, 0.879975, 0.721671, 0.843364, 0.710745, 0.843364, 0.988723, 0.666494, 0.988723, 0.656988, 0.721671, 0.329452, 0.70488, 0.992415, 0.988723, 0.992415, 0.988723, 0.656988, 0.70488, 0.329452, 0.70488, 0.992415, 0.496983, 0.992415, 0.496983, 0.776873, 0.775996, 0.776873, 0.775996, 0.62187, 0.92696, 0.598481, 0.92696, 0.980404, 0.851052, 0.643923, 0.851052, 0.163147, 0.988723, 0.019055, 0.988723, 0.980404, 0.851052, 0.371069, 0.851052, 0.734458, 0.988723, 0.734458, 0.988723, 0.656988, 0.669151, 0.371069, 0.355461, 0.734458, 0.496983, 0.734458, 0.496983, 0.776873, 0.775996, 0.776873, 0.775996, 0.766823, 0.92696, 0.619422, 0.92696, 0.980404, 0.862041, 0.766823, 0.851052, 0.766823, 0.972916, 0.619422, 0.972916, 0.980404, 0.862041, 0.744106, 0.851052, 0.744106, 0.972916, 0.556507, 0.972916, 0.051677, 0.669151, 0.371069, -0.585768, 0.371069, 0.005911, -0.207482, 0.005911, 0.396366, 0.284132, 0.766823, 0.284132, 0.766823, 0.30151, 0.619422, 0.30151, 0.396366, 0.862041, 0.766823, -0.018503, 0.766823, 0.30151, 0.619422, 0.30151, 0.051677, 0.862041, 0.744106, -0.018503, 0.744106, 0.005911, 0.556507, 0.005911, 0.051677, -0.201239, 0.202332, -0.585768, 0.202332, 0.005911, -0.410351, 0.005911]\n"
     ]
    }
   ],
   "source": [
    "data_in_shape = (4, 4, 4, 2)\n",
    "L = MaxPooling3D(pool_size=(2, 2, 2), strides=(1, 1, 1), padding='same', data_format='channels_last')\n",
    "\n",
    "layer_0 = Input(shape=data_in_shape)\n",
    "layer_1 = L(layer_0)\n",
    "model = Model(inputs=layer_0, outputs=layer_1)\n",
    "\n",
    "# set weights to random (use seed for reproducibility)\n",
    "np.random.seed(286)\n",
    "data_in = 2 * np.random.random(data_in_shape) - 1\n",
    "result = model.predict(np.array([data_in]))\n",
    "data_out_shape = result[0].shape\n",
    "data_in_formatted = format_decimal(data_in.ravel().tolist())\n",
    "data_out_formatted = format_decimal(result[0].ravel().tolist())\n",
    "print('')\n",
    "print('in shape:', data_in_shape)\n",
    "print('in:', data_in_formatted)\n",
    "print('out shape:', data_out_shape)\n",
    "print('out:', data_out_formatted)\n",
    "\n",
    "DATA['pooling.MaxPooling3D.6'] = {\n",
    "    'input': {'data': data_in_formatted, 'shape': data_in_shape},\n",
    "    'expected': {'data': data_out_formatted, 'shape': data_out_shape}\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**[pooling.MaxPooling3D.7] input 4x5x4x2, pool_size=(2, 2, 2), strides=(1, 2, 1), padding='same', data_format='channels_last'**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "in shape: (4, 5, 4, 2)\n",
      "in: [-0.71103, 0.421506, 0.752321, 0.542455, -0.557162, -0.963774, 0.910303, -0.933284, 0.67521, 0.588709, -0.782848, -0.108964, -0.767069, 0.338318, -0.660374, -0.967294, -0.501079, -0.917532, -0.087991, -0.160473, 0.520493, 0.612007, -0.955448, -0.809749, -0.627003, 0.494441, 0.985405, 0.99813, -0.278165, 0.090068, 0.803872, 0.287682, 0.162199, 0.1796, -0.630223, 0.044743, 0.9092, 0.023879, -0.403203, -0.005329, -0.29237, -0.510033, -0.190427, 0.149011, 0.873547, -0.58793, -0.302525, 0.102122, -0.804112, 0.965834, 0.302039, -0.806929, 0.627682, 0.876256, 0.176245, 0.051969, 0.005712, -0.877694, -0.776877, -0.360984, 0.172577, 0.953108, 0.755911, 0.973515, 0.745292, 0.765506, 0.119956, 0.378346, 0.425789, 0.048668, 0.363691, -0.499862, 0.315721, 0.243267, 0.333434, -0.001645, -0.007235, -0.463152, -0.002048, 0.862117, -0.575785, 0.594789, 0.068012, 0.165267, 0.081581, 0.128645, 0.559305, -0.494595, 0.10207, 0.278472, -0.815856, 0.817863, 0.101417, -0.432774, -0.36832, 0.682055, -0.852236, 0.756063, 0.741739, 0.403911, 0.363444, -0.853088, 0.429379, 0.95063, 0.19365, 0.707334, 0.883575, 0.037535, 0.735855, -0.597979, -0.328964, -0.63363, 0.533345, 0.628204, -0.831273, -0.475492, -0.120719, -0.049689, 0.474126, -0.534385, 0.898272, -0.060213, 0.134975, -0.81603, -0.09329, -0.56951, 0.744421, 0.561587, -0.094, 0.780616, -0.206093, 0.992174, 0.563806, 0.562612, -0.754387, -0.36159, -0.288989, 0.195871, -0.156575, 0.108674, 0.037465, 0.115865, -0.313897, -0.290763, -0.920174, -0.943574, 0.610507, -0.749795, -0.802955, 0.296183, -0.862404, 0.174227, 0.6721, 0.674769, -0.198663, 0.163696, -0.572753, 0.149323, 0.456671, 0.162098]\n",
      "out shape: (4, 3, 4, 2)\n",
      "out: [0.752321, 0.965834, 0.873547, 0.876256, 0.910303, 0.876256, 0.910303, 0.102122, 0.985405, 0.99813, 0.985405, 0.99813, 0.803872, 0.973515, 0.803872, 0.973515, 0.333434, 0.243267, 0.9092, 0.044743, 0.9092, 0.862117, -0.002048, 0.862117, 0.302039, 0.965834, 0.873547, 0.876256, 0.873547, 0.876256, 0.559305, 0.682055, 0.883575, 0.765506, 0.883575, 0.953108, 0.755911, 0.973515, 0.755911, 0.973515, 0.533345, 0.628204, 0.333434, -0.001645, 0.474126, 0.862117, 0.474126, 0.862117, 0.898272, 0.992174, 0.563806, 0.992174, 0.744421, 0.682055, 0.744421, 0.682055, 0.883575, 0.756063, 0.883575, 0.403911, 0.735855, 0.95063, 0.429379, 0.95063, 0.6721, 0.674769, -0.120719, 0.163696, 0.474126, 0.162098, 0.474126, 0.162098, 0.898272, 0.992174, 0.563806, 0.992174, 0.744421, 0.562612, 0.744421, 0.561587, 0.610507, 0.195871, 0.610507, 0.296183, 0.037465, 0.296183, -0.313897, 0.174227, 0.6721, 0.674769, -0.198663, 0.163696, 0.456671, 0.162098, 0.456671, 0.162098]\n"
     ]
    }
   ],
   "source": [
    "data_in_shape = (4, 5, 4, 2)\n",
    "L = MaxPooling3D(pool_size=(2, 2, 2), strides=(1, 2, 1), padding='same', data_format='channels_last')\n",
    "\n",
    "layer_0 = Input(shape=data_in_shape)\n",
    "layer_1 = L(layer_0)\n",
    "model = Model(inputs=layer_0, outputs=layer_1)\n",
    "\n",
    "# set weights to random (use seed for reproducibility)\n",
    "np.random.seed(287)\n",
    "data_in = 2 * np.random.random(data_in_shape) - 1\n",
    "result = model.predict(np.array([data_in]))\n",
    "data_out_shape = result[0].shape\n",
    "data_in_formatted = format_decimal(data_in.ravel().tolist())\n",
    "data_out_formatted = format_decimal(result[0].ravel().tolist())\n",
    "print('')\n",
    "print('in shape:', data_in_shape)\n",
    "print('in:', data_in_formatted)\n",
    "print('out shape:', data_out_shape)\n",
    "print('out:', data_out_formatted)\n",
    "\n",
    "DATA['pooling.MaxPooling3D.7'] = {\n",
    "    'input': {'data': data_in_formatted, 'shape': data_in_shape},\n",
    "    'expected': {'data': data_out_formatted, 'shape': data_out_shape}\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**[pooling.MaxPooling3D.8] input 4x4x4x2, pool_size=(3, 3, 3), strides=None, padding='same', data_format='channels_last'**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "in shape: (4, 4, 4, 2)\n",
      "in: [0.106539, 0.430065, 0.625063, -0.956042, 0.681684, 0.345995, -0.589061, 0.186737, 0.535452, -0.125905, -0.396262, -0.44893, 0.39021, 0.253402, -0.238515, 0.337141, 0.178107, 0.244331, -0.93179, -0.081267, 0.895223, 0.820023, 0.365435, -0.738456, 0.893031, -0.787916, -0.518813, 0.661518, -0.464144, -0.639165, -0.252917, 0.784083, 0.577398, 0.769552, 0.036096, 0.847521, -0.171916, 0.07536, -0.830068, 0.734205, -0.437818, 0.295701, 0.252657, -0.859452, -0.425833, -0.650296, -0.584695, 0.163986, 0.43905, -0.521755, 0.620616, 0.066707, -0.101702, 0.941175, 0.479202, 0.624312, -0.372154, 0.625845, 0.980521, -0.834695, -0.40269, 0.784157, 0.814068, -0.485038, -0.150738, 0.682911, 0.406096, -0.405868, -0.337905, 0.803583, -0.764964, 0.96897, -0.057235, 0.403604, -0.605392, 0.389273, 0.235543, -0.095585, -0.860692, 0.937457, -0.928888, 0.702073, -0.18066, 0.033968, -0.082046, -0.237205, 0.922919, 0.064731, -0.026908, -0.865491, 0.881128, 0.265603, -0.132321, -0.701801, 0.490064, 0.718745, -0.884446, 0.538162, -0.086979, -0.734317, 0.089006, 0.349945, -0.415428, -0.621358, 0.892372, 0.090398, 0.883604, 0.772612, 0.589633, 0.187399, 0.807184, -0.128627, -0.534439, 0.258966, 0.141399, -0.777263, 0.911318, -0.359087, 0.789361, 0.470019, 0.836149, 0.415029, 0.920315, -0.916153, 0.645573, -0.446523, -0.899169, 0.78844]\n",
      "out shape: (2, 2, 2, 2)\n",
      "out: [0.625063, 0.847521, 0.681684, 0.734205, 0.980521, 0.661518, 0.895223, 0.941175, 0.892372, 0.772612, 0.807184, 0.96897, 0.920315, 0.702073, 0.922919, 0.78844]\n"
     ]
    }
   ],
   "source": [
    "data_in_shape = (4, 4, 4, 2)\n",
    "L = MaxPooling3D(pool_size=(3, 3, 3), strides=None, padding='same', data_format='channels_last')\n",
    "\n",
    "layer_0 = Input(shape=data_in_shape)\n",
    "layer_1 = L(layer_0)\n",
    "model = Model(inputs=layer_0, outputs=layer_1)\n",
    "\n",
    "# set weights to random (use seed for reproducibility)\n",
    "np.random.seed(288)\n",
    "data_in = 2 * np.random.random(data_in_shape) - 1\n",
    "result = model.predict(np.array([data_in]))\n",
    "data_out_shape = result[0].shape\n",
    "data_in_formatted = format_decimal(data_in.ravel().tolist())\n",
    "data_out_formatted = format_decimal(result[0].ravel().tolist())\n",
    "print('')\n",
    "print('in shape:', data_in_shape)\n",
    "print('in:', data_in_formatted)\n",
    "print('out shape:', data_out_shape)\n",
    "print('out:', data_out_formatted)\n",
    "\n",
    "DATA['pooling.MaxPooling3D.8'] = {\n",
    "    'input': {'data': data_in_formatted, 'shape': data_in_shape},\n",
    "    'expected': {'data': data_out_formatted, 'shape': data_out_shape}\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**[pooling.MaxPooling3D.9] input 4x4x4x2, pool_size=(3, 3, 3), strides=(3, 3, 3), padding='same', data_format='channels_last'**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "in shape: (4, 4, 4, 2)\n",
      "in: [0.454263, 0.047178, -0.644362, 0.432654, 0.776147, -0.088086, -0.16527, -0.152361, -0.723283, 0.119471, -0.020663, 0.230897, 0.249349, -0.825224, 0.809245, 0.37136, 0.649976, 0.690981, -0.5766, 0.750394, -0.777363, -0.359006, 0.398419, -0.851015, -0.479232, -0.924962, -0.898893, 0.135445, 0.819369, -0.867218, 0.039715, 0.304805, -0.865872, -0.891635, 0.730554, 0.178083, 0.981329, 0.047786, -0.466968, -0.89441, -0.037018, -0.880158, 0.635061, 0.108217, 0.405675, 0.242025, 0.524396, -0.46013, -0.98454, 0.227442, -0.159924, -0.396205, -0.843265, 0.181395, -0.743803, 0.445469, 0.05215, 0.837067, -0.756402, -0.959109, -0.580594, -0.677936, -0.929683, -0.165592, -0.870784, 0.91887, 0.542361, 0.46359, -0.521332, 0.778263, 0.662447, 0.692057, 0.224535, -0.087731, 0.904644, 0.207457, -0.564079, -0.389642, 0.590403, -0.861828, -0.280471, -0.593786, -0.542645, 0.788946, -0.808773, -0.334536, -0.973711, 0.68675, 0.383992, -0.38838, 0.278601, -0.89188, -0.582918, -0.190511, -0.493528, 0.635115, -0.375152, 0.586508, -0.986557, -0.449484, 0.216757, 0.746825, -0.144795, 0.448144, -0.828083, 0.224525, -0.958965, -0.566069, -0.850394, -0.261458, -0.589888, 0.75667, 0.531888, 0.146437, -0.877887, -0.575355, 0.06156, -0.714865, 0.710365, -0.439259, -0.084566, -0.854224, 0.467254, 0.59934, 0.527409, 0.791222, -0.66992, 0.644258]\n",
      "out shape: (2, 2, 2, 2)\n",
      "out: [0.730554, 0.432654, 0.981329, 0.37136, 0.649976, 0.837067, 0.819369, 0.445469, 0.904644, 0.91887, 0.662447, 0.778263, 0.531888, 0.788946, 0.710365, 0.791222]\n"
     ]
    }
   ],
   "source": [
    "data_in_shape = (4, 4, 4, 2)\n",
    "L = MaxPooling3D(pool_size=(3, 3, 3), strides=(3, 3, 3), padding='same', data_format='channels_last')\n",
    "\n",
    "layer_0 = Input(shape=data_in_shape)\n",
    "layer_1 = L(layer_0)\n",
    "model = Model(inputs=layer_0, outputs=layer_1)\n",
    "\n",
    "# set weights to random (use seed for reproducibility)\n",
    "np.random.seed(289)\n",
    "data_in = 2 * np.random.random(data_in_shape) - 1\n",
    "result = model.predict(np.array([data_in]))\n",
    "data_out_shape = result[0].shape\n",
    "data_in_formatted = format_decimal(data_in.ravel().tolist())\n",
    "data_out_formatted = format_decimal(result[0].ravel().tolist())\n",
    "print('')\n",
    "print('in shape:', data_in_shape)\n",
    "print('in:', data_in_formatted)\n",
    "print('out shape:', data_out_shape)\n",
    "print('out:', data_out_formatted)\n",
    "\n",
    "DATA['pooling.MaxPooling3D.9'] = {\n",
    "    'input': {'data': data_in_formatted, 'shape': data_in_shape},\n",
    "    'expected': {'data': data_out_formatted, 'shape': data_out_shape}\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**[pooling.MaxPooling3D.10] input 2x3x3x4, pool_size=(3, 3, 3), strides=(2, 2, 2), padding='valid', data_format='channels_first'**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "in shape: (2, 3, 3, 4)\n",
      "in: [-0.453175, -0.475078, 0.486234, -0.949643, -0.349099, -0.837108, 0.933439, 0.167853, -0.995191, 0.459466, -0.788337, -0.120985, 0.06215, 0.138625, -0.102201, 0.976605, -0.591051, -0.592066, 0.469334, -0.435067, 0.621416, 0.817698, 0.790015, 0.485862, 0.469679, -0.611443, 0.582845, -0.503885, -0.379174, -0.451035, 0.052289, 0.131836, -0.609312, -0.828722, -0.422428, -0.648754, -0.339801, -0.758017, 0.754244, -0.544823, 0.691656, 0.076848, -0.32539, 0.306448, -0.662415, 0.334329, 0.030666, -0.414111, -0.757096, -0.20427, -0.893088, -0.681919, -0.619269, -0.640749, 0.867436, 0.971453, -0.42039, -0.574905, -0.34642, 0.588678, -0.247265, 0.436084, 0.220126, 0.114202, 0.613623, 0.401452, -0.270262, -0.591146, -0.872383, 0.818368, 0.336808, 0.338197]\n",
      "out shape: (2, 1, 1, 1)\n",
      "out: [0.933439, 0.867436]\n"
     ]
    }
   ],
   "source": [
    "data_in_shape = (2, 3, 3, 4)\n",
    "L = MaxPooling3D(pool_size=(3, 3, 3), strides=(2, 2, 2), padding='valid', data_format='channels_first')\n",
    "\n",
    "layer_0 = Input(shape=data_in_shape)\n",
    "layer_1 = L(layer_0)\n",
    "model = Model(inputs=layer_0, outputs=layer_1)\n",
    "\n",
    "# set weights to random (use seed for reproducibility)\n",
    "np.random.seed(290)\n",
    "data_in = 2 * np.random.random(data_in_shape) - 1\n",
    "result = model.predict(np.array([data_in]))\n",
    "data_out_shape = result[0].shape\n",
    "data_in_formatted = format_decimal(data_in.ravel().tolist())\n",
    "data_out_formatted = format_decimal(result[0].ravel().tolist())\n",
    "print('')\n",
    "print('in shape:', data_in_shape)\n",
    "print('in:', data_in_formatted)\n",
    "print('out shape:', data_out_shape)\n",
    "print('out:', data_out_formatted)\n",
    "\n",
    "DATA['pooling.MaxPooling3D.10'] = {\n",
    "    'input': {'data': data_in_formatted, 'shape': data_in_shape},\n",
    "    'expected': {'data': data_out_formatted, 'shape': data_out_shape}\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**[pooling.MaxPooling3D.11] input 2x3x3x4, pool_size=(3, 3, 3), strides=(1, 1, 1), padding='same', data_format='channels_first'**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "in shape: (2, 3, 3, 4)\n",
      "in: [-0.803361, 0.348731, 0.30124, -0.168638, 0.516406, -0.258765, 0.297839, 0.993235, 0.958465, -0.273175, -0.704992, 0.261477, -0.301255, 0.263104, 0.678631, -0.644936, -0.029034, -0.320266, 0.307733, -0.479016, 0.608177, 0.034951, 0.456908, -0.929353, 0.594982, -0.243058, -0.524918, 0.455339, 0.034216, 0.356824, 0.63906, -0.259773, -0.084724, 0.248472, -0.608134, 0.0077, 0.400591, -0.960703, -0.247926, -0.774509, 0.496174, -0.319044, -0.324046, -0.616632, -0.322142, -0.472846, 0.171825, -0.030013, 0.992861, -0.645264, 0.524886, 0.673229, 0.883122, 0.25346, -0.706988, -0.654436, 0.918349, -0.139113, 0.742737, 0.338472, -0.812719, 0.860081, 0.003489, 0.667897, 0.362284, -0.283972, 0.995162, 0.67962, -0.700244, -0.137142, 0.045695, -0.450433]\n",
      "out shape: (2, 3, 3, 4)\n",
      "out: [0.516406, 0.678631, 0.993235, 0.993235, 0.958466, 0.958466, 0.993235, 0.993235, 0.958466, 0.958466, 0.993235, 0.993235, 0.594982, 0.678631, 0.993235, 0.993235, 0.958466, 0.958466, 0.993235, 0.993235, 0.958466, 0.958466, 0.993235, 0.993235, 0.594982, 0.678631, 0.678631, 0.678631, 0.608177, 0.678631, 0.678631, 0.678631, 0.608177, 0.63906, 0.63906, 0.63906, 0.992861, 0.992861, 0.673229, 0.673229, 0.992861, 0.992861, 0.742737, 0.742737, 0.918348, 0.918348, 0.742737, 0.742737, 0.992861, 0.995162, 0.995162, 0.995162, 0.992861, 0.995162, 0.995162, 0.995162, 0.918348, 0.995162, 0.995162, 0.995162, 0.992861, 0.995162, 0.995162, 0.995162, 0.992861, 0.995162, 0.995162, 0.995162, 0.918348, 0.995162, 0.995162, 0.995162]\n"
     ]
    }
   ],
   "source": [
    "data_in_shape = (2, 3, 3, 4)\n",
    "L = MaxPooling3D(pool_size=(3, 3, 3), strides=(1, 1, 1), padding='same', data_format='channels_first')\n",
    "\n",
    "layer_0 = Input(shape=data_in_shape)\n",
    "layer_1 = L(layer_0)\n",
    "model = Model(inputs=layer_0, outputs=layer_1)\n",
    "\n",
    "# set weights to random (use seed for reproducibility)\n",
    "np.random.seed(291)\n",
    "data_in = 2 * np.random.random(data_in_shape) - 1\n",
    "result = model.predict(np.array([data_in]))\n",
    "data_out_shape = result[0].shape\n",
    "data_in_formatted = format_decimal(data_in.ravel().tolist())\n",
    "data_out_formatted = format_decimal(result[0].ravel().tolist())\n",
    "print('')\n",
    "print('in shape:', data_in_shape)\n",
    "print('in:', data_in_formatted)\n",
    "print('out shape:', data_out_shape)\n",
    "print('out:', data_out_formatted)\n",
    "\n",
    "DATA['pooling.MaxPooling3D.11'] = {\n",
    "    'input': {'data': data_in_formatted, 'shape': data_in_shape},\n",
    "    'expected': {'data': data_out_formatted, 'shape': data_out_shape}\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**[pooling.MaxPooling3D.12] input 3x4x4x3, pool_size=(2, 2, 2), strides=None, padding='valid', data_format='channels_first'**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "in shape: (3, 4, 4, 3)\n",
      "in: [-0.497409, -0.250345, 0.196124, -0.044334, -0.324906, 0.560065, 0.220435, -0.167776, -0.923771, 0.77337, -0.862909, -0.584756, -0.70451, 0.870272, 0.841773, -0.312016, 0.599915, 0.073955, 0.944336, -0.4175, 0.865698, 0.609184, 0.033839, -0.72494, -0.239473, 0.514968, -0.318523, -0.244443, 0.275468, -0.85993, -0.262732, 0.026767, -0.937574, 0.872647, 0.540013, 0.055422, 0.322167, 0.972206, 0.92596, -0.82368, -0.63508, 0.671616, -0.678809, 0.202761, -0.260164, -0.241878, 0.188534, -0.47291, -0.077436, -0.016304, 0.548747, -0.236224, -0.780147, -0.013071, -0.67362, -0.807763, -0.351361, 0.533701, 0.274553, -0.933379, -0.49029, 0.928012, -0.719924, 0.453519, 0.173223, 0.030778, 0.12229, 0.547074, -0.860491, 0.206434, 0.248515, -0.189106, -0.393127, -0.152128, -0.822508, -0.361768, -0.702917, 0.998304, -0.011396, -0.644766, -0.150506, -0.153633, -0.772981, -0.470261, -0.056372, 0.082635, 0.017418, 0.26302, 0.730468, 0.268813, -0.163174, 0.332229, -0.698119, -0.397122, -0.426552, -0.931893, -0.6652, -0.986456, -0.062208, -0.90263, -0.12278, -0.277462, 0.072233, 0.466157, -0.917268, 0.053668, -0.45609, 0.072386, 0.376642, 0.133363, -0.799663, -0.984724, 0.337956, -0.088779, -0.04311, 0.520989, -0.611655, -0.456082, -0.662569, 0.09705, 0.256941, -0.987104, -0.939188, -0.296892, 0.123336, 0.710366, -0.675095, -0.037022, -0.616184, -0.925359, -0.734003, -0.629605, 0.071318, 0.6548, -0.019787, -0.435663, -0.412123, 0.967997, -0.80066, -0.337085, 0.471011, -0.945095, -0.74401, 0.924175]\n",
      "out shape: (3, 2, 2, 1)\n",
      "out: [0.870272, 0.944336, 0.972206, 0.872647, 0.928012, 0.547073, 0.730468, 0.332229, 0.376642, 0.520989, 0.6548, -0.037022]\n"
     ]
    }
   ],
   "source": [
    "data_in_shape = (3, 4, 4, 3)\n",
    "L = MaxPooling3D(pool_size=(2, 2, 2), strides=None, padding='valid', data_format='channels_first')\n",
    "\n",
    "layer_0 = Input(shape=data_in_shape)\n",
    "layer_1 = L(layer_0)\n",
    "model = Model(inputs=layer_0, outputs=layer_1)\n",
    "\n",
    "# set weights to random (use seed for reproducibility)\n",
    "np.random.seed(292)\n",
    "data_in = 2 * np.random.random(data_in_shape) - 1\n",
    "result = model.predict(np.array([data_in]))\n",
    "data_out_shape = result[0].shape\n",
    "data_in_formatted = format_decimal(data_in.ravel().tolist())\n",
    "data_out_formatted = format_decimal(result[0].ravel().tolist())\n",
    "print('')\n",
    "print('in shape:', data_in_shape)\n",
    "print('in:', data_in_formatted)\n",
    "print('out shape:', data_out_shape)\n",
    "print('out:', data_out_formatted)\n",
    "\n",
    "DATA['pooling.MaxPooling3D.12'] = {\n",
    "    'input': {'data': data_in_formatted, 'shape': data_in_shape},\n",
    "    'expected': {'data': data_out_formatted, 'shape': data_out_shape}\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "### export for Keras.js tests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import os\n",
    "\n",
    "filename = '../../../test/data/layers/pooling/MaxPooling3D.json'\n",
    "if not os.path.exists(os.path.dirname(filename)):\n",
    "    os.makedirs(os.path.dirname(filename))\n",
    "with open(filename, 'w') as f:\n",
    "    json.dump(DATA, f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"pooling.MaxPooling3D.0\": {\"input\": {\"data\": [-0.453175, -0.475078, 0.486234, -0.949643, -0.349099, -0.837108, 0.933439, 0.167853, -0.995191, 0.459466, -0.788337, -0.120985, 0.06215, 0.138625, -0.102201, 0.976605, -0.591051, -0.592066, 0.469334, -0.435067, 0.621416, 0.817698, 0.790015, 0.485862, 0.469679, -0.611443, 0.582845, -0.503885, -0.379174, -0.451035, 0.052289, 0.131836, -0.609312, -0.828722, -0.422428, -0.648754, -0.339801, -0.758017, 0.754244, -0.544823, 0.691656, 0.076848, -0.32539, 0.306448, -0.662415, 0.334329, 0.030666, -0.414111, -0.757096, -0.20427, -0.893088, -0.681919, -0.619269, -0.640749, 0.867436, 0.971453, -0.42039, -0.574905, -0.34642, 0.588678, -0.247265, 0.436084, 0.220126, 0.114202, 0.613623, 0.401452, -0.270262, -0.591146, -0.872383, 0.818368, 0.336808, 0.338197, -0.275646, 0.375308, -0.928722, -0.836727, -0.504007, -0.503397, -0.636099, 0.948482, -0.639661, -0.026878, -0.122643, -0.634018, -0.247016, 0.517246, -0.398639, 0.752174, -0.014633, -0.170534, -0.463453, -0.289716, 0.837207, 0.769962, -0.401357, 0.076406, 0.270433, -0.036538, -0.05766, 0.625256, 0.626847, -0.27321, -0.217219, -0.775553, -0.182939, 0.327385, -0.976376, -0.337729, -0.178467, -0.1545, -0.334259, -0.537949, 0.499229, 0.775269, -0.657598, 0.921864, 0.376821, 0.420375, -0.937835, -0.176425, -0.516753, 0.737286, 0.867807, -0.515893, 0.710035, 0.680377, -0.350561, -0.28645], \"shape\": [4, 4, 4, 2]}, \"expected\": {\"data\": [0.691656, 0.459466, 0.933439, 0.976605, 0.582845, 0.588678, 0.867436, 0.971453, 0.613623, 0.625256, 0.626847, 0.948482, 0.867807, 0.921864, 0.837207, 0.769962], \"shape\": [2, 2, 2, 2]}}, \"pooling.MaxPooling3D.1\": {\"input\": {\"data\": [-0.803361, 0.348731, 0.30124, -0.168638, 0.516406, -0.258765, 0.297839, 0.993235, 0.958465, -0.273175, -0.704992, 0.261477, -0.301255, 0.263104, 0.678631, -0.644936, -0.029034, -0.320266, 0.307733, -0.479016, 0.608177, 0.034951, 0.456908, -0.929353, 0.594982, -0.243058, -0.524918, 0.455339, 0.034216, 0.356824, 0.63906, -0.259773, -0.084724, 0.248472, -0.608134, 0.0077, 0.400591, -0.960703, -0.247926, -0.774509, 0.496174, -0.319044, -0.324046, -0.616632, -0.322142, -0.472846, 0.171825, -0.030013, 0.992861, -0.645264, 0.524886, 0.673229, 0.883122, 0.25346, -0.706988, -0.654436, 0.918349, -0.139113, 0.742737, 0.338472, -0.812719, 0.860081, 0.003489, 0.667897, 0.362284, -0.283972, 0.995162, 0.67962, -0.700244, -0.137142, 0.045695, -0.450433, 0.929977, 0.157542, -0.720517, -0.939063, 0.295004, 0.308728, -0.094057, -0.374756, -0.400976, -0.539654, 0.27965, 0.977688, -0.361264, -0.027757, -0.67149, 0.57064, -0.861888, 0.616985, -0.027436, 0.40181, -0.30391, 0.92268, -0.486416, -0.335828, 0.138558, -0.445691, 0.156253, -0.967633, 0.127471, -0.783301, -0.691353, -0.76759, 0.618771, -0.377474, 0.50152, 0.126867, -0.872708, 0.649418, 0.697987, -0.33456, 0.906767, 0.604333, -0.129366, 0.579445, -0.033479, -0.22433, -0.979529, -0.251153, 0.839734, 0.550506, -0.599678, 0.584326, 0.211245, -0.66845, 0.948298, -0.004521], \"shape\": [4, 4, 4, 2]}, \"expected\": {\"data\": [0.958466, 0.348731, 0.516406, 0.263104, 0.678631, 0.993235, 0.992861, 0.673229, 0.883122, 0.673229, 0.883122, 0.263104, 0.992861, 0.673229, 0.883122, 0.860081, 0.883122, 0.860081, 0.995162, 0.67962, 0.995162, 0.67962, 0.400591, 0.308728, 0.992861, 0.977688, 0.883122, 0.977688, 0.883122, 0.57064, 0.992861, 0.977688, 0.883122, 0.977688, 0.883122, 0.92268, 0.995162, 0.67962, 0.995162, 0.67962, 0.697987, 0.649418, 0.929977, 0.977688, 0.50152, 0.977688, 0.697987, 0.649418, 0.906767, 0.977688, 0.27965, 0.977688, 0.948298, 0.92268], \"shape\": [3, 3, 3, 2]}}, \"pooling.MaxPooling3D.2\": {\"input\": {\"data\": [-0.263147, -0.216555, -0.75766, -0.396007, 0.85243, 0.98415, -0.230197, -0.979579, 0.117628, -0.66833, 0.714058, -0.907302, -0.574249, 0.299573, 0.101165, 0.655872, -0.104788, 0.242064, -0.409262, -0.124059, 0.105687, -0.969325, -0.167941, 0.382377, 0.710487, 0.793042, 0.180663, -0.80231, 0.684253, -0.516992, 0.471203, -0.152325, 0.509501, 0.613742, -0.877379, 0.755416, 0.427677, 0.931956, 0.827636, -0.860685, 0.562326, -0.716081, 0.028046, 0.594422, -0.862333, 0.336131, 0.713855, 0.386247, -0.986659, 0.242413, 0.753777, -0.159358, 0.166548, -0.437388, 0.291152, -0.775555, 0.796086, -0.592021, -0.251661, 0.187174, 0.899283, 0.431861, -0.685273, -0.085991, -0.629026, -0.478334, 0.714983, 0.53745, -0.310438, 0.973848, -0.675219, 0.422743, -0.992263, 0.374017, -0.687462, -0.190455, -0.560081, 0.22484, -0.079631, 0.815275, 0.338641, -0.538279, -0.10891, -0.929005, 0.514762, 0.322038, 0.702195, -0.697122, 0.925468, -0.274158, 0.148379, 0.333239, 0.63072, -0.652956, -0.356451, -0.71114, 0.111465, 0.31787, 0.242578, 0.8926, -0.60807, 0.218759, 0.42079, 0.71253, -0.082496, 0.272704, 0.277213, -0.099807, -0.899322, -0.175367, -0.642213, -0.661032, 0.730145, 0.37799, 0.935939, -0.448007, -0.320652, -0.352629, 0.258139, 0.30254], \"shape\": [4, 5, 2, 3]}, \"expected\": {\"data\": [0.613742, 0.931956, 0.98415, 0.655872, 0.931956, 0.827636, 0.655872, 0.713855, 0.753777, 0.710487, 0.793042, 0.796086, 0.973848, 0.53745, 0.63072, 0.973848, 0.71253, 0.422743, 0.42079, 0.815275, 0.37799, 0.935939, 0.925468, 0.702195], \"shape\": [2, 4, 1, 3]}}, \"pooling.MaxPooling3D.3\": {\"input\": {\"data\": [0.19483, -0.346754, 0.281648, -0.656271, 0.588328, 0.864284, -0.661556, 0.344578, 0.534692, 0.187914, -0.172976, 0.100575, 0.287857, 0.151936, 0.679748, 0.137527, 0.726773, -0.503042, -0.902524, -0.895315, 0.870645, 0.792427, -0.102238, -0.748643, -0.048728, -0.025835, 0.358631, 0.804295, -0.300104, -0.99179, -0.699454, -0.943476, -0.448011, 0.628611, 0.060595, 0.716813, -0.33607, 0.549002, 0.810379, 0.074881, -0.689823, 0.17513, -0.975426, 0.961779, -0.030624, -0.914643, -0.735591, 0.031988, -0.554272, 0.253033, 0.73405, 0.426412, -0.361457, 0.787875, -0.266747, -0.166595, 0.922155, -0.04597, -0.465312, 0.157074, -0.201136, -0.004584, -0.158067, 0.244864, -0.495687, 0.416834, -0.583545, 0.654634, -0.318258, -0.709804, -0.393463, 0.589381, -0.900991, 0.266171, 0.955916, -0.6571, 0.990855, -0.078764, 0.609356, -0.526011, -0.902476, 0.040574, -0.045497, -0.110604, 0.035908, -0.91532, -0.170028, -0.02148, -0.994139, 0.020418, 0.989168, -0.802385, 0.353583, -0.981395, -0.959128, 0.785969, -0.325003, -0.541583, -0.929888, 0.40832, 0.565713, 0.449217, -0.21377, -0.491438, -0.352481, 0.469042, 0.272024, 0.101279, -0.70562, -0.296457, 0.210789, -0.049051, -0.002596, 0.630726, 0.023403, -0.216062, 0.510835, -0.446393, -0.075211, 0.4807, 0.581605, 0.705887, 0.741715, -0.448041, 0.88241, -0.866934, -0.341714, -0.245376], \"shape\": [4, 4, 4, 2]}, \"expected\": {\"data\": [0.990855, 0.961779], \"shape\": [1, 1, 1, 2]}}, \"pooling.MaxPooling3D.4\": {\"input\": {\"data\": [0.691755, -0.79282, -0.953135, 0.756956, -0.736874, 0.171061, -0.801845, 0.588236, -0.884749, 0.06721, -0.585121, -0.546211, -0.605281, -0.998989, 0.309413, -0.260604, -0.123585, 0.168908, -0.179496, 0.657412, -0.973664, 0.146258, -0.851615, -0.320588, 0.375102, -0.048494, 0.822789, 0.063572, -0.956466, 0.083595, 0.121146, 0.789353, -0.815498, -0.056454, -0.472042, -0.423572, 0.460752, 0.784129, -0.964421, -0.02912, -0.194265, 0.17147, -0.336383, -0.785223, 0.978845, 0.88826, -0.498649, -0.958507, 0.055052, -0.991654, -0.027882, 0.079693, 0.901998, 0.036266, -0.73015, -0.472116, 0.651073, 0.821196, 0.562183, 0.42342, -0.236111, 0.661076, -0.983951, -0.116893, -0.179815, 0.375962, -0.018703, -0.242038, -0.561415, 0.322072, 0.468695, 0.768235, -0.354887, 0.528139, 0.796988, -0.976979, 0.279858, -0.790546, 0.485339, 0.693701, -0.130412, 0.211269, -0.346429, 0.06497, 0.932512, -0.675758, -0.636085, 0.065187, -0.720225, -0.060809, -0.783716, -0.1708, 0.256143, 0.365727, -0.458241, 0.515217, -0.269055, 0.378065, 0.066507, 0.207271, -0.303131, 0.632455, 0.147251, 0.35156, -0.852052, -0.382054, 0.42108, -0.350071, 0.092818, 0.516404, 0.448487, 0.503722, -0.86555, 0.747871, 0.320894, -0.163714, 0.107681, 0.562623, 0.757089, 0.85338, -0.875069, 0.324594, -0.093024, 0.016279, -0.507882, -0.549638, -0.913588, 0.078328], \"shape\": [4, 4, 4, 2]}, \"expected\": {\"data\": [0.978845, 0.88826], \"shape\": [1, 1, 1, 2]}}, \"pooling.MaxPooling3D.5\": {\"input\": {\"data\": [-0.495196, -0.886872, 0.220815, 0.126844, 0.168234, -0.640849, 0.457897, -0.375014, 0.001134, -0.486501, -0.819617, -0.468351, 0.15859, 0.39238, -0.590545, -0.402922, 0.821619, -0.208255, -0.512219, -0.586151, -0.365648, -0.195611, -0.280978, -0.08818, -0.449229, 0.169082, 0.075074, -0.719751, 0.657827, -0.060862, -0.217533, 0.907503, 0.902317, 0.613945, 0.670047, -0.808346, 0.060215, -0.446612, -0.710328, -0.018744, 0.348018, -0.294409, 0.623986, -0.216504, 0.270099, -0.216285, -0.433193, -0.197968, -0.829926, -0.93864, -0.901724, -0.388869, -0.658339, -0.931401, -0.654674, -0.469503, 0.970661, 0.008063, -0.751014, 0.519043, 0.197895, 0.959095, 0.875405, 0.700615, 0.301314, -0.980157, 0.275373, -0.082646, 0.100727, -0.027273, -0.322366, 0.26563, 0.668139, 0.890289, 0.854229, -0.85773, -0.07833, -0.319645, -0.948873, 0.403526, 0.683097, 0.174958, 0.926944, -0.418256, -0.406667, -0.333808, 0.102223, -0.00576, 0.182281, 0.979655, 0.230246, 0.422968, -0.381217, 0.146697, 0.660828, 0.060741, -0.201812, 0.587619, 0.188211, -0.652713, -0.937225, -0.814998, 0.277993, -0.539363, -0.665425, 0.72739, 0.919326, 0.710163, -0.819091, -0.089805, -0.778517, -0.593048, 0.945303, -0.078936, 0.303422, 0.206755, -0.899923, -0.868598, 0.249905, -0.47891, 0.006871, -0.263386, -0.484493, -0.75917, 0.857292, 0.401094, -0.077826, -0.44546], \"shape\": [4, 4, 4, 2]}, \"expected\": {\"data\": [0.902317, 0.613945, 0.457897, 0.39238, 0.970661, 0.519043, 0.875405, 0.959095, 0.919326, 0.890289, 0.277993, 0.403526, 0.945303, 0.979655, 0.857292, 0.401094], \"shape\": [2, 2, 2, 2]}}, \"pooling.MaxPooling3D.6\": {\"input\": {\"data\": [-0.709952, -0.532913, -0.169956, -0.391538, 0.729034, -0.2004, -0.67324, -0.973672, 0.879975, -0.981827, -0.4828, -0.887985, 0.843364, 0.710745, -0.260613, 0.20082, 0.309563, 0.721671, -0.967848, -0.976471, -0.13058, 0.052684, 0.666494, -0.319759, -0.060338, 0.359151, -0.795562, 0.70488, 0.100816, 0.466479, 0.992415, 0.066527, -0.690663, -0.741365, -0.251801, -0.479328, 0.62187, 0.578729, 0.598481, 0.817115, -0.913801, -0.694569, 0.397726, -0.31274, 0.163147, 0.087004, -0.744957, -0.920201, 0.440377, -0.191648, -0.227724, -0.562736, -0.484598, -0.230876, 0.019055, 0.988723, 0.656988, 0.185623, -0.629304, -0.321252, 0.329452, 0.355461, 0.734458, 0.496983, 0.181439, 0.414232, 0.776873, 0.68191, -0.846744, -0.442164, -0.526272, 0.92696, -0.704629, -0.800248, 0.643923, 0.775996, -0.203863, -0.756864, -0.398058, -0.914275, 0.980404, 0.329099, -0.576086, 0.851052, -0.74133, -0.23673, -0.001628, 0.972916, -0.571033, 0.669151, -0.977945, -0.707472, 0.371069, -0.772292, -0.207482, -0.094619, -0.604913, 0.111706, -0.123427, 0.284132, 0.292284, -0.490954, -0.873365, 0.109881, -0.40172, 0.103223, 0.396366, -0.415444, 0.766823, -0.057373, 0.619422, 0.30151, -0.126582, 0.862041, -0.083425, -0.018503, 0.744106, -0.681409, 0.556506, -0.628066, -0.697587, -0.201239, 0.051677, -0.585768, 0.202332, -0.634928, -0.410351, 0.005911], \"shape\": [4, 4, 4, 2]}, \"expected\": {\"data\": [0.879975, -0.31274, 0.843364, 0.710745, 0.843364, 0.817115, 0.598481, 0.817115, 0.879975, 0.721671, 0.843364, 0.710745, 0.843364, 0.988723, 0.666494, 0.988723, 0.656988, 0.721671, 0.329452, 0.70488, 0.992415, 0.988723, 0.992415, 0.988723, 0.656988, 0.70488, 0.329452, 0.70488, 0.992415, 0.496983, 0.992415, 0.496983, 0.776873, 0.775996, 0.776873, 0.775996, 0.62187, 0.92696, 0.598481, 0.92696, 0.980404, 0.851052, 0.643923, 0.851052, 0.163147, 0.988723, 0.019055, 0.988723, 0.980404, 0.851052, 0.371069, 0.851052, 0.734458, 0.988723, 0.734458, 0.988723, 0.656988, 0.669151, 0.371069, 0.355461, 0.734458, 0.496983, 0.734458, 0.496983, 0.776873, 0.775996, 0.776873, 0.775996, 0.766823, 0.92696, 0.619422, 0.92696, 0.980404, 0.862041, 0.766823, 0.851052, 0.766823, 0.972916, 0.619422, 0.972916, 0.980404, 0.862041, 0.744106, 0.851052, 0.744106, 0.972916, 0.556507, 0.972916, 0.051677, 0.669151, 0.371069, -0.585768, 0.371069, 0.005911, -0.207482, 0.005911, 0.396366, 0.284132, 0.766823, 0.284132, 0.766823, 0.30151, 0.619422, 0.30151, 0.396366, 0.862041, 0.766823, -0.018503, 0.766823, 0.30151, 0.619422, 0.30151, 0.051677, 0.862041, 0.744106, -0.018503, 0.744106, 0.005911, 0.556507, 0.005911, 0.051677, -0.201239, 0.202332, -0.585768, 0.202332, 0.005911, -0.410351, 0.005911], \"shape\": [4, 4, 4, 2]}}, \"pooling.MaxPooling3D.7\": {\"input\": {\"data\": [-0.71103, 0.421506, 0.752321, 0.542455, -0.557162, -0.963774, 0.910303, -0.933284, 0.67521, 0.588709, -0.782848, -0.108964, -0.767069, 0.338318, -0.660374, -0.967294, -0.501079, -0.917532, -0.087991, -0.160473, 0.520493, 0.612007, -0.955448, -0.809749, -0.627003, 0.494441, 0.985405, 0.99813, -0.278165, 0.090068, 0.803872, 0.287682, 0.162199, 0.1796, -0.630223, 0.044743, 0.9092, 0.023879, -0.403203, -0.005329, -0.29237, -0.510033, -0.190427, 0.149011, 0.873547, -0.58793, -0.302525, 0.102122, -0.804112, 0.965834, 0.302039, -0.806929, 0.627682, 0.876256, 0.176245, 0.051969, 0.005712, -0.877694, -0.776877, -0.360984, 0.172577, 0.953108, 0.755911, 0.973515, 0.745292, 0.765506, 0.119956, 0.378346, 0.425789, 0.048668, 0.363691, -0.499862, 0.315721, 0.243267, 0.333434, -0.001645, -0.007235, -0.463152, -0.002048, 0.862117, -0.575785, 0.594789, 0.068012, 0.165267, 0.081581, 0.128645, 0.559305, -0.494595, 0.10207, 0.278472, -0.815856, 0.817863, 0.101417, -0.432774, -0.36832, 0.682055, -0.852236, 0.756063, 0.741739, 0.403911, 0.363444, -0.853088, 0.429379, 0.95063, 0.19365, 0.707334, 0.883575, 0.037535, 0.735855, -0.597979, -0.328964, -0.63363, 0.533345, 0.628204, -0.831273, -0.475492, -0.120719, -0.049689, 0.474126, -0.534385, 0.898272, -0.060213, 0.134975, -0.81603, -0.09329, -0.56951, 0.744421, 0.561587, -0.094, 0.780616, -0.206093, 0.992174, 0.563806, 0.562612, -0.754387, -0.36159, -0.288989, 0.195871, -0.156575, 0.108674, 0.037465, 0.115865, -0.313897, -0.290763, -0.920174, -0.943574, 0.610507, -0.749795, -0.802955, 0.296183, -0.862404, 0.174227, 0.6721, 0.674769, -0.198663, 0.163696, -0.572753, 0.149323, 0.456671, 0.162098], \"shape\": [4, 5, 4, 2]}, \"expected\": {\"data\": [0.752321, 0.965834, 0.873547, 0.876256, 0.910303, 0.876256, 0.910303, 0.102122, 0.985405, 0.99813, 0.985405, 0.99813, 0.803872, 0.973515, 0.803872, 0.973515, 0.333434, 0.243267, 0.9092, 0.044743, 0.9092, 0.862117, -0.002048, 0.862117, 0.302039, 0.965834, 0.873547, 0.876256, 0.873547, 0.876256, 0.559305, 0.682055, 0.883575, 0.765506, 0.883575, 0.953108, 0.755911, 0.973515, 0.755911, 0.973515, 0.533345, 0.628204, 0.333434, -0.001645, 0.474126, 0.862117, 0.474126, 0.862117, 0.898272, 0.992174, 0.563806, 0.992174, 0.744421, 0.682055, 0.744421, 0.682055, 0.883575, 0.756063, 0.883575, 0.403911, 0.735855, 0.95063, 0.429379, 0.95063, 0.6721, 0.674769, -0.120719, 0.163696, 0.474126, 0.162098, 0.474126, 0.162098, 0.898272, 0.992174, 0.563806, 0.992174, 0.744421, 0.562612, 0.744421, 0.561587, 0.610507, 0.195871, 0.610507, 0.296183, 0.037465, 0.296183, -0.313897, 0.174227, 0.6721, 0.674769, -0.198663, 0.163696, 0.456671, 0.162098, 0.456671, 0.162098], \"shape\": [4, 3, 4, 2]}}, \"pooling.MaxPooling3D.8\": {\"input\": {\"data\": [0.106539, 0.430065, 0.625063, -0.956042, 0.681684, 0.345995, -0.589061, 0.186737, 0.535452, -0.125905, -0.396262, -0.44893, 0.39021, 0.253402, -0.238515, 0.337141, 0.178107, 0.244331, -0.93179, -0.081267, 0.895223, 0.820023, 0.365435, -0.738456, 0.893031, -0.787916, -0.518813, 0.661518, -0.464144, -0.639165, -0.252917, 0.784083, 0.577398, 0.769552, 0.036096, 0.847521, -0.171916, 0.07536, -0.830068, 0.734205, -0.437818, 0.295701, 0.252657, -0.859452, -0.425833, -0.650296, -0.584695, 0.163986, 0.43905, -0.521755, 0.620616, 0.066707, -0.101702, 0.941175, 0.479202, 0.624312, -0.372154, 0.625845, 0.980521, -0.834695, -0.40269, 0.784157, 0.814068, -0.485038, -0.150738, 0.682911, 0.406096, -0.405868, -0.337905, 0.803583, -0.764964, 0.96897, -0.057235, 0.403604, -0.605392, 0.389273, 0.235543, -0.095585, -0.860692, 0.937457, -0.928888, 0.702073, -0.18066, 0.033968, -0.082046, -0.237205, 0.922919, 0.064731, -0.026908, -0.865491, 0.881128, 0.265603, -0.132321, -0.701801, 0.490064, 0.718745, -0.884446, 0.538162, -0.086979, -0.734317, 0.089006, 0.349945, -0.415428, -0.621358, 0.892372, 0.090398, 0.883604, 0.772612, 0.589633, 0.187399, 0.807184, -0.128627, -0.534439, 0.258966, 0.141399, -0.777263, 0.911318, -0.359087, 0.789361, 0.470019, 0.836149, 0.415029, 0.920315, -0.916153, 0.645573, -0.446523, -0.899169, 0.78844], \"shape\": [4, 4, 4, 2]}, \"expected\": {\"data\": [0.625063, 0.847521, 0.681684, 0.734205, 0.980521, 0.661518, 0.895223, 0.941175, 0.892372, 0.772612, 0.807184, 0.96897, 0.920315, 0.702073, 0.922919, 0.78844], \"shape\": [2, 2, 2, 2]}}, \"pooling.MaxPooling3D.9\": {\"input\": {\"data\": [0.454263, 0.047178, -0.644362, 0.432654, 0.776147, -0.088086, -0.16527, -0.152361, -0.723283, 0.119471, -0.020663, 0.230897, 0.249349, -0.825224, 0.809245, 0.37136, 0.649976, 0.690981, -0.5766, 0.750394, -0.777363, -0.359006, 0.398419, -0.851015, -0.479232, -0.924962, -0.898893, 0.135445, 0.819369, -0.867218, 0.039715, 0.304805, -0.865872, -0.891635, 0.730554, 0.178083, 0.981329, 0.047786, -0.466968, -0.89441, -0.037018, -0.880158, 0.635061, 0.108217, 0.405675, 0.242025, 0.524396, -0.46013, -0.98454, 0.227442, -0.159924, -0.396205, -0.843265, 0.181395, -0.743803, 0.445469, 0.05215, 0.837067, -0.756402, -0.959109, -0.580594, -0.677936, -0.929683, -0.165592, -0.870784, 0.91887, 0.542361, 0.46359, -0.521332, 0.778263, 0.662447, 0.692057, 0.224535, -0.087731, 0.904644, 0.207457, -0.564079, -0.389642, 0.590403, -0.861828, -0.280471, -0.593786, -0.542645, 0.788946, -0.808773, -0.334536, -0.973711, 0.68675, 0.383992, -0.38838, 0.278601, -0.89188, -0.582918, -0.190511, -0.493528, 0.635115, -0.375152, 0.586508, -0.986557, -0.449484, 0.216757, 0.746825, -0.144795, 0.448144, -0.828083, 0.224525, -0.958965, -0.566069, -0.850394, -0.261458, -0.589888, 0.75667, 0.531888, 0.146437, -0.877887, -0.575355, 0.06156, -0.714865, 0.710365, -0.439259, -0.084566, -0.854224, 0.467254, 0.59934, 0.527409, 0.791222, -0.66992, 0.644258], \"shape\": [4, 4, 4, 2]}, \"expected\": {\"data\": [0.730554, 0.432654, 0.981329, 0.37136, 0.649976, 0.837067, 0.819369, 0.445469, 0.904644, 0.91887, 0.662447, 0.778263, 0.531888, 0.788946, 0.710365, 0.791222], \"shape\": [2, 2, 2, 2]}}, \"pooling.MaxPooling3D.10\": {\"input\": {\"data\": [-0.453175, -0.475078, 0.486234, -0.949643, -0.349099, -0.837108, 0.933439, 0.167853, -0.995191, 0.459466, -0.788337, -0.120985, 0.06215, 0.138625, -0.102201, 0.976605, -0.591051, -0.592066, 0.469334, -0.435067, 0.621416, 0.817698, 0.790015, 0.485862, 0.469679, -0.611443, 0.582845, -0.503885, -0.379174, -0.451035, 0.052289, 0.131836, -0.609312, -0.828722, -0.422428, -0.648754, -0.339801, -0.758017, 0.754244, -0.544823, 0.691656, 0.076848, -0.32539, 0.306448, -0.662415, 0.334329, 0.030666, -0.414111, -0.757096, -0.20427, -0.893088, -0.681919, -0.619269, -0.640749, 0.867436, 0.971453, -0.42039, -0.574905, -0.34642, 0.588678, -0.247265, 0.436084, 0.220126, 0.114202, 0.613623, 0.401452, -0.270262, -0.591146, -0.872383, 0.818368, 0.336808, 0.338197], \"shape\": [2, 3, 3, 4]}, \"expected\": {\"data\": [0.933439, 0.867436], \"shape\": [2, 1, 1, 1]}}, \"pooling.MaxPooling3D.11\": {\"input\": {\"data\": [-0.803361, 0.348731, 0.30124, -0.168638, 0.516406, -0.258765, 0.297839, 0.993235, 0.958465, -0.273175, -0.704992, 0.261477, -0.301255, 0.263104, 0.678631, -0.644936, -0.029034, -0.320266, 0.307733, -0.479016, 0.608177, 0.034951, 0.456908, -0.929353, 0.594982, -0.243058, -0.524918, 0.455339, 0.034216, 0.356824, 0.63906, -0.259773, -0.084724, 0.248472, -0.608134, 0.0077, 0.400591, -0.960703, -0.247926, -0.774509, 0.496174, -0.319044, -0.324046, -0.616632, -0.322142, -0.472846, 0.171825, -0.030013, 0.992861, -0.645264, 0.524886, 0.673229, 0.883122, 0.25346, -0.706988, -0.654436, 0.918349, -0.139113, 0.742737, 0.338472, -0.812719, 0.860081, 0.003489, 0.667897, 0.362284, -0.283972, 0.995162, 0.67962, -0.700244, -0.137142, 0.045695, -0.450433], \"shape\": [2, 3, 3, 4]}, \"expected\": {\"data\": [0.516406, 0.678631, 0.993235, 0.993235, 0.958466, 0.958466, 0.993235, 0.993235, 0.958466, 0.958466, 0.993235, 0.993235, 0.594982, 0.678631, 0.993235, 0.993235, 0.958466, 0.958466, 0.993235, 0.993235, 0.958466, 0.958466, 0.993235, 0.993235, 0.594982, 0.678631, 0.678631, 0.678631, 0.608177, 0.678631, 0.678631, 0.678631, 0.608177, 0.63906, 0.63906, 0.63906, 0.992861, 0.992861, 0.673229, 0.673229, 0.992861, 0.992861, 0.742737, 0.742737, 0.918348, 0.918348, 0.742737, 0.742737, 0.992861, 0.995162, 0.995162, 0.995162, 0.992861, 0.995162, 0.995162, 0.995162, 0.918348, 0.995162, 0.995162, 0.995162, 0.992861, 0.995162, 0.995162, 0.995162, 0.992861, 0.995162, 0.995162, 0.995162, 0.918348, 0.995162, 0.995162, 0.995162], \"shape\": [2, 3, 3, 4]}}, \"pooling.MaxPooling3D.12\": {\"input\": {\"data\": [-0.497409, -0.250345, 0.196124, -0.044334, -0.324906, 0.560065, 0.220435, -0.167776, -0.923771, 0.77337, -0.862909, -0.584756, -0.70451, 0.870272, 0.841773, -0.312016, 0.599915, 0.073955, 0.944336, -0.4175, 0.865698, 0.609184, 0.033839, -0.72494, -0.239473, 0.514968, -0.318523, -0.244443, 0.275468, -0.85993, -0.262732, 0.026767, -0.937574, 0.872647, 0.540013, 0.055422, 0.322167, 0.972206, 0.92596, -0.82368, -0.63508, 0.671616, -0.678809, 0.202761, -0.260164, -0.241878, 0.188534, -0.47291, -0.077436, -0.016304, 0.548747, -0.236224, -0.780147, -0.013071, -0.67362, -0.807763, -0.351361, 0.533701, 0.274553, -0.933379, -0.49029, 0.928012, -0.719924, 0.453519, 0.173223, 0.030778, 0.12229, 0.547074, -0.860491, 0.206434, 0.248515, -0.189106, -0.393127, -0.152128, -0.822508, -0.361768, -0.702917, 0.998304, -0.011396, -0.644766, -0.150506, -0.153633, -0.772981, -0.470261, -0.056372, 0.082635, 0.017418, 0.26302, 0.730468, 0.268813, -0.163174, 0.332229, -0.698119, -0.397122, -0.426552, -0.931893, -0.6652, -0.986456, -0.062208, -0.90263, -0.12278, -0.277462, 0.072233, 0.466157, -0.917268, 0.053668, -0.45609, 0.072386, 0.376642, 0.133363, -0.799663, -0.984724, 0.337956, -0.088779, -0.04311, 0.520989, -0.611655, -0.456082, -0.662569, 0.09705, 0.256941, -0.987104, -0.939188, -0.296892, 0.123336, 0.710366, -0.675095, -0.037022, -0.616184, -0.925359, -0.734003, -0.629605, 0.071318, 0.6548, -0.019787, -0.435663, -0.412123, 0.967997, -0.80066, -0.337085, 0.471011, -0.945095, -0.74401, 0.924175], \"shape\": [3, 4, 4, 3]}, \"expected\": {\"data\": [0.870272, 0.944336, 0.972206, 0.872647, 0.928012, 0.547073, 0.730468, 0.332229, 0.376642, 0.520989, 0.6548, -0.037022], \"shape\": [3, 2, 2, 1]}}}\n"
     ]
    }
   ],
   "source": [
    "print(json.dumps(DATA))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
